/*
 * Timer.h

 *
 *  Created on: Nov 5, 2014
 *      Author: root
 */

/*								!VERY IMPORTANT!
 * GO TO Project properties -> c/c++ build -> Settings -> GCC C Linker -> Libraries
 * And include the “pthread” library into the other libraries.
 * Click Apply and rebuild the project.
*/

#include <iostream>
#include <pthread.h>

#ifndef TIMER_H_
#define TIMER_H_


namespace TimerNameSpace {

/**
 *  Timer is a class that implements counting down methods.
 */
class Timer {

public:
	int timeOut;
	pthread_t *killThread;
	bool CountDown(signed int *seconds); //decrease 'seconds' in background (seconds-=1)
	void* TimeOutFunc(void* func(void *), void* funcParam, int TimeOut); //call the functio 'func' and terminate after 'timeOut' (seconds).

private:

	static void* Counting(void* sec);
	static void* KillThreadByTimeOut(void* args);

};


} /* namespace TimerNameSpace */



#endif /* TIMER_H_ */
